// components/fileshow/fileshow.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
	  np : {
		  type:String,
		  value:null
			
	  }
  },

  /**
   * 组件的初始数据
   */
  data: {
	  list:[],
	  isshow:true
  },
  
  /**
   * 组件的方法列表
   */
  lifetimes:{
	  ready(){
		 this.getdata();
	  }
  },
  methods: {
	  download(filename){
		let that=this;
		let app=getApp();
		console.log(filename.target.dataset.filename[0]);
		wx.downloadFile({
		  url: app.globalData.ip+'file/download/'+filename.target.dataset.filename[0],
		  success : (res)=>{
			  wx.openDocument({
				 filePath: res.tempFilePath,
			  })
		  }
		})
	  },
	  getdata(){
		  let that=this;
		  let app=getApp();
		  wx.request({
			url: app.globalData.ip+'file/getfilenames/'+that.properties.np,
			success: (res)=>{
				console.log(res.data);
				console.log(res.data.code);
				let d=res.data;
				if(d.code==200){
					that.setData({
						list:d.data,
						isshow:true
					})
				}
				else{
					that.setData({
						list:null,
						isshow:false
					})
				}		
			}
		 })
	  }
  }
})